/*
 * ArtistTableModel.java
 *
 * Created on June 11, 2005, 12:34 PM
 */
package com.bff.slimserver.musicjukebox.lib;

import com.bff.bjj.utils.Resources.LABEL_KEY;
import org.bff.slimserver.exception.SlimException;
import org.bff.slimserver.musicobjects.SlimArtist;
import org.bff.slimserver.musicobjects.SlimSong;

/**
 *
 * @author Bill
 */
public class ArtistTableModel extends SongTableModel {

    public static final int ALBUM = 0;
    public static final int TITLE = 1;
    public static final int LENGTH = 2;
    public static final int YEAR = 3;
    public static final int BITRATE = 4;
    public final static String[] columnNames = {
        getHeader(LABEL_KEY.HEADER_ALBUM),
        getHeader(LABEL_KEY.HEADER_TITLE),
        getHeader(LABEL_KEY.HEADER_LENGTH),
        getHeader(LABEL_KEY.HEADER_YEAR),
        getHeader(LABEL_KEY.HEADER_BITRATE)
    };

    /** Creates a new instance of TassTableModel */
    public ArtistTableModel(SlimArtist artist) throws SlimException {
        super(JukeboxProperties.getInstance().getDatabase().listSongsForArtist(artist));
    }

    public ArtistTableModel(java.util.Collection songs) {
        super(songs);
    }

    @Override
    public int getRowCount() {
        return (dataList.size());
    }

    @Override
    public Object getValueAt(int row, int col) {
        SlimSong song = dataList.get(row);
        switch (col) {
            case (ALBUM):
                return getAlbumTitle(song);
            case (TITLE):
                return getSongTitle(song);
            case (LENGTH):
                return (song.getLength());
            case (YEAR):
                return (song.getYear());
            /*
            case(GENRE):
            return(song.getGenre());
             */
            case (BITRATE):
                return (song.getBitrate());
            default:
                return (null);
        }
    }

    @Override
    public int getColumnCount() {
        return (columnNames.length);
    }

    @Override
    public String getColumnName(int column) {
        return columnNames[column];
    }

    @Override
    public int getArtistColumnIndex() {
        return (-1);
    }

    @Override
    public int getAlbumColumnIndex() {
        return (ALBUM);
    }

    @Override
    public int getTitleColumnIndex() {
        return (TITLE);
    }

    @Override
    public int getLengthColumnIndex() {
        return (LENGTH);
    }

    @Override
    public int getTrackColumnIndex() {
        return (-1);
    }

    @Override
    public int getYearColumnIndex() {
        return (YEAR);
    }

    /*
    public int getGenreColumnIndex() {
    return(GENRE);
    }
     */
    @Override
    public int getBitrateColumnIndex() {
        return (BITRATE);
    }

    @Override
    public int getSortColumn() {
        return getAlbumColumnIndex();
    }
}
